# /**
# * Copyright (c) 2022 Beijing Jiaotong University
# * PhotLab is licensed under [Open Source License].
# * You can use this software according to the terms and conditions of the [Open Source License].
# *
# * You may obtain a copy of [Open Source License] at: [https://open.source.license/]
# *
# * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# *
# * See the [Open Source License] for more details.
# */
# /**
# * Author: Shihao Xie
# * Created: Jul. 7, 2023
# * Supported by: National Key Research and Development Program of China
# */

import uuid
from ctypes import c_int32


def to_i32(n) -> int:
    if n < 0:
        n = (1 << 31) + n
    return c_int32(n).value

def to_i64(n) -> int:
    if n < 0:
        n = (1 << 64) + n
    return c_int32(n).value

def generate_uuid(name:str = None) -> int:
    if name is not None:
        return abs(to_i32(int(uuid.uuid3(uuid.NAMESPACE_DNS, name))))
    # return abs(to_i32(int(uuid.uuid4())))
    return abs(to_i32(int(uuid.uuid4())))

# def generate_uuid(stri) -> int:
#     pass

if __name__ == "__main__":
    print(generate_uuid())
